/**
 * Copyright (c) 2012, Ken Anderson, Brent Mucci
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/

#ifndef MCL_IMAGE_H
#define MCL_IMAGE_H

#include "mcl_common.h"

namespace mcl
{

// Class for handling images internally.
// The image format is 32-bit, RGBA (8 bits per channel)
class Image
{
public:
	// Constructor/deconstructor
	Image();
	~Image();

	// Accessors
	unsigned int getWidth()  const { return m_width; }
	unsigned int getHeight() const { return m_height; }
	unsigned int getPitch()  const { return m_pitch; }
	unsigned char * data()   const { return m_pData; }

	// Initializes by setting the height, width, and allocates the data buffer.
	// If the parameters are the same, the function is lazy and doesn't do anything.
	// Returns true if successful.
	bool init(int w, int h);

	// Flips the Y axis of the selected rectangle of the image
	// Returns true if successful.
	bool flipY();

	// Generate checkerboard pattern
	// The seed is used to offset the checkerboard image in the vertical direction.
	// Returns true if successful.
	bool generateCheckerboard(int seed);

private:
	unsigned int m_width;
	unsigned int m_height;
	unsigned int m_pitch;
	unsigned char * m_pData;
};

}; // namespace

#endif
